function Evaluate_Segmentation()

load('mydata', 'pos', 'pos2');   % groundTruth 
resultdir      =    './weizmann_horse_db/result/';
sampleNum   =   length(pos);
test        =   pos2(sampleNum/2+1:end);

for n=1:length(test)
    fn = [resultdir  test(n).im(end-11:end) '.png'];
    ls = imread(fn)>128;
    gt = Get_GroundTruth_Fname(test(n).im)>128;
    tt = gt == ls;
    sa(n) = sum(tt(:))/numel(gt); 
    tt = (ls&gt); 
    tt2 = (ls|gt);
    sb(n) = sum(tt(:))/sum(tt2(:));
    disp([fn '---sa:' num2str(sa(n)), '---sb:' num2str(sb(n)) ]);
    
end    
exi     =   sb>0;
disp('---------------------------------------------------');
disp('----------------final result-----------------------');
disp('---------------------------------------------------');
disp(['total sa:' num2str(sum(sa(exi))/length(exi))]);
disp(['total sb:' num2str(sum(sb(exi))/length(exi))]);

[inst_v, inst_id] = sort(sb);
inst_id(1:20)


function im = Get_GroundTruth_Fname(fn)
   f  = fn(end-11:end);
   im = imread(['./weizmann_horse_db/figure_ground/', f]);